package com.zcgame.floatview.testdemo

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.zcgame.floatview.R

/**
 *@author:huangLJ
 *@date:2021/7/9 18:16
 */
class MainAdapter: RecyclerView.Adapter<MainAdapter.InnerHolder>() {



    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): InnerHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_main_adapter, parent, false)
        return InnerHolder(view)
    }

    override fun getItemCount(): Int {
        return 5
    }

    override fun onBindViewHolder(holder: InnerHolder, position: Int) {
        holder.bind(position)
    }
    class InnerHolder(itemView: View):RecyclerView.ViewHolder(itemView) {
        fun bind(position: Int) {
            val text = itemView.findViewById<TextView>(R.id.text)
            text.text = position.toString()
        }
    }
}